<template>
  <div class="app-container jkpkhfxmzxyj">
    <!-- <span class="title">个人申请与审核</span>
    <el-divider></el-divider> -->
    <div class="filter-container">
      <el-form inline>
        <el-form-item label="所属区县">
          <el-select placeholder="所属区县" v-model="listQuery.district">
            <el-option v-for="(item,index) in quxianList" :key="index" :label="item.name" :value="item.id" />
          </el-select>
        </el-form-item>
        <el-form-item label="开始时间">
          <el-date-picker
            v-model="listQuery.startTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="开始时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="截止时间">
          <el-date-picker
            v-model="listQuery.stopTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="截止时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button @click="changePage()" type="primary">查询</el-button>
          <el-button @click="daochu()" type="primary">导出报表</el-button>
        </el-form-item>
      </el-form>
    </div>

    <el-table :show-header="false" :span-method="arraySpanMethod" v-loading="listLoading" border :data="list" element-loading-text="加载中">
      <el-table-column align="center" prop="name" label="类别">
        <el-table-column align="center" prop="name"  width="50"></el-table-column>
        <el-table-column align="center" prop="subName"  width="120"></el-table-column>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip prop="renshu" label="行政区"></el-table-column>
      <el-table-column align="center" show-overflow-tooltip prop="hushu" label="总计"></el-table-column>
      <el-table-column align="center" show-overflow-tooltip label="在办项目">
        <el-table-column align="center" show-overflow-tooltip prop="guimo" label="小计"></el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="renshu1" label="地票交易"></el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="hushu1" label="增减挂钩"></el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="guimo1" label="拆旧建新"></el-table-column>
      </el-table-column>
      <el-table-column align="center" show-overflow-tooltip label="已办结项目">
        <el-table-column align="center" show-overflow-tooltip prop="renshu2" label="小计"></el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="hushu2" label="地票交易"></el-table-column>
        <el-table-column align="center" show-overflow-tooltip prop="guimo2" label="增减挂钩"></el-table-column>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getList,findDetailByDictionaryType,getLandAuditStatus } from "@/api/project/fksqtc/personApplyCheck";
import { projectPoorHouseholdSurvey,getDistList } from "@/api/tongji";

export default {
  filters: {},
  data() {
    return {
      list: null,
      total: null,
      listLoading: false,
      listQuery: {
        startTime:'',
        stopTime:'',
        district:'',
      },
      shenChaList:[], //审查类型列表
      fukenList:[], //复垦类型列表
      quxianList:[],
    };
  },
  created() {
    this.getData()
    this.getAreaData()
  },
  methods: {
    //导出
    daochu(){
      var a = document.createElement("a");
      var obj = ""
      var checkNullorNot = 0
      var objArr = this.listQuery
      for (var index in objArr) {
        if(objArr[index]!==''&&objArr[index]!=null){
          obj += "&" + index + "=" + objArr[index]
          checkNullorNot++
        }
      }
      if(checkNullorNot != 0){
        obj = obj.substr(1)
        obj = '?' + obj
      }
      console.log(obj,"携带参数")
      a.setAttribute(
        "href",
        this.$https +
          "/pc/project/export/export_project_poor_household_survey" + obj
      );
      a.click();
    },
    //获取所有区县
    getAreaData(){
      getDistList().then(res =>{
        this.quxianList = res.data
      })
    },
    //获取表格数据
    getData(){
      this.listLoading = true
      var data={}
      var objArr=this.listQuery
      for (var index in objArr) {
        if(objArr[index]!==''&&objArr[index]!=null){
          data[index]=objArr[index];
        }
      }
      for (var dataIndex in data){
        if(dataIndex == "startTime" || dataIndex == "stopTime"){
          data[dataIndex] = data[dataIndex] + " " + "00:00:00"
        }
      }
      projectPoorHouseholdSurvey(data).then(res =>{
        this.listLoading = false
        console.log(res,"表格数据")
        var arr=[]
          arr.push({name:'建卡贫困户农村建设用地复垦项目情况',subName:'区县申报备案',renshu:res.data[0].poorNumberTotal,hushu:res.data[0].poorHouseholdsTotal,guimo:res.data[0].poorScaleTotal,renshu1:res.data[0].poorYearNumberTotal,hushu1:res.data[0].poorYearHouseholdsTotal,guimo1:res.data[0].poorYearScaleTotal,renshu2:res.data[0].poorMonthNumberTotal,hushu2:res.data[0].poorMonthHouseholdsTotal,guimo2:res.data[0].poorMonthScaleTotal})
          arr.push({name:'建卡贫困户农村建设用地复垦项目情况',subName:'市级已备案',renshu:res.data[1].poorNumberTotal,hushu:res.data[1].poorHouseholdsTotal,guimo:res.data[1].poorScaleTotal,renshu1:res.data[1].poorYearNumberTotal,hushu1:res.data[1].poorYearHouseholdsTotal,guimo1:res.data[1].poorYearScaleTotal,renshu2:res.data[1].poorMonthNumberTotal,hushu2:res.data[1].poorMonthHouseholdsTotal,guimo2:res.data[1].poorMonthScaleTotal})
          arr.push({name:'建卡贫困户农村建设用地复垦项目情况',subName:'已开工实施',renshu:res.data[2].poorNumberTotal,hushu:res.data[2].poorHouseholdsTotal,guimo:res.data[2].poorScaleTotal,renshu1:res.data[2].poorYearNumberTotal,hushu1:res.data[2].poorYearHouseholdsTotal,guimo1:res.data[2].poorYearScaleTotal,renshu2:res.data[2].poorMonthNumberTotal,hushu2:res.data[2].poorMonthHouseholdsTotal,guimo2:res.data[2].poorMonthScaleTotal})
          arr.push({name:'建卡贫困户农村建设用地复垦项目情况',subName:'已复垦竣工',renshu:res.data[3].poorNumberTotal,hushu:res.data[3].poorHouseholdsTotal,guimo:res.data[3].poorScaleTotal,renshu1:res.data[3].poorYearNumberTotal,hushu1:res.data[3].poorYearHouseholdsTotal,guimo1:res.data[3].poorYearScaleTotal,renshu2:res.data[3].poorMonthNumberTotal,hushu2:res.data[3].poorMonthHouseholdsTotal,guimo2:res.data[3].poorMonthScaleTotal})
          arr.push({name:'建卡贫困户农村建设用地复垦项目情况',subName:'区县已验收',renshu:res.data[4].poorNumberTotal,hushu:res.data[4].poorHouseholdsTotal,guimo:res.data[4].poorScaleTotal,renshu1:res.data[4].poorYearNumberTotal,hushu1:res.data[4].poorYearHouseholdsTotal,guimo1:res.data[4].poorYearScaleTotal,renshu2:res.data[4].poorMonthNumberTotal,hushu2:res.data[4].poorMonthHouseholdsTotal,guimo2:res.data[4].poorMonthScaleTotal})
          arr.push({name:'建卡贫困户农村建设用地复垦项目情况',subName:'市级抽查复核',renshu:res.data[5].poorNumberTotal,hushu:res.data[5].poorHouseholdsTotal,guimo:res.data[5].poorScaleTotal,renshu1:res.data[5].poorYearNumberTotal,hushu1:res.data[5].poorYearHouseholdsTotal,guimo1:res.data[5].poorYearScaleTotal,renshu2:res.data[5].poorMonthNumberTotal,hushu2:res.data[5].poorMonthHouseholdsTotal,guimo2:res.data[5].poorMonthScaleTotal})
          arr.push({name:'建卡贫困户农村建设用地复垦项目情况',subName:'市级已配号',renshu:res.data[6].poorNumberTotal,hushu:res.data[6].poorHouseholdsTotal,guimo:res.data[6].poorScaleTotal,renshu1:res.data[6].poorYearNumberTotal,hushu1:res.data[6].poorYearHouseholdsTotal,guimo1:res.data[6].poorYearScaleTotal,renshu2:res.data[6].poorMonthNumberTotal,hushu2:res.data[6].poorMonthHouseholdsTotal,guimo2:res.data[6].poorMonthScaleTotal})
          this.list = arr
          //重构表头
          this.list.unshift({name:'类别',subName:'类别',renshu:'人数',hushu:'户数',guimo:'规模',renshu1:'人数',hushu1:'户数',guimo1:'规模',renshu2:'人数',hushu2:'户数',guimo2:'规模'})
          this.list.unshift({name:'类别',subName:'类别',renshu:'累计当年建卡贫困户总体情况',hushu:'无',guimo:'无',renshu1:'当年新增',hushu1:'无',guimo1:'无',renshu2:'当月新增',hushu2:'无',guimo2:'无'})
      }).catch(err =>{
        this.listLoading = false
      })
    },
    arraySpanMethod({ row, column, rowIndex, columnIndex }) {
      console.log(row, column, rowIndex, columnIndex)
      if(columnIndex === 0 && rowIndex === 0){
        return [2, 2];
      }
      if(columnIndex === 1 && rowIndex === 0){
        return [0, 0];
      }
      if(columnIndex === 0 && rowIndex === 1){
        return [0, 0];
      }
      if(columnIndex === 1 && rowIndex === 1){
        return [0, 0];
      }
      if(columnIndex === 2 && rowIndex === 0){
        return [1, 3];
      }
      if(columnIndex === 3 && rowIndex === 0){
        return [0, 0];
      }
      if(columnIndex === 4 && rowIndex === 0){
        return [0, 0];
      }
      if(columnIndex === 5 && rowIndex === 0){
        return [1, 3];
      }
      if(columnIndex === 6 && rowIndex === 0){
        return [0, 0];
      }
      if(columnIndex === 7 && rowIndex === 0){
        return [0, 0];
      }
      if(columnIndex === 8 && rowIndex === 0){
        return [1, 3];
      }
      if(columnIndex === 9 && rowIndex === 0){
        return [0, 0];
      }
      if(columnIndex === 10 && rowIndex === 0){
        return [0, 0];
      }

      if (columnIndex === 0 && rowIndex === 2) {
        return [7, 1];
      }else if (columnIndex === 0 && (rowIndex == 3 || rowIndex == 4 || rowIndex == 5 || rowIndex == 6 || rowIndex == 7 || rowIndex == 8)) {
        return [0, 0];
      }else if (columnIndex === 0 && (rowIndex == 9 || rowIndex == 10)) {
        return [1, 2];
      }
      if (columnIndex === 1 && (rowIndex == 9 || rowIndex == 10)) {
        return [0, 0];
      }
    },
    changePage(page) {
      this.getData();
    }
  }
};
</script>
<style lang="css" scoped>
  .jkpkhfxmzxyj /deep/ .el-table--enable-row-hover .el-table__body tr:hover>td{
    background: #fff;
  }
</style>